# Created by admin on 2018/4/23.

import io

class HtmlOutper(object):
    def __init__(self):
        self.datas = []

    def collect_data(self, data):
        if data is None:
            return
        self.datas.append(data)

    def output_html(self):
        fout = open('output.html', 'w')
        fout.write("<html><body><table border='1px solid blue'>")
        # ascii
        for data in self.datas:
            fout.write('<tr>')
            fout.write("<td width='20px'>%s</td>" % data['url'])
            fout.write("<td >%s</td>" % data['title'])
            fout.write("<td >%s</td>" % data['summary'])
            fout.write('</tr>')
        fout.write("</table></body></html>")
        fout.close()
